package com.sojson.task;

import java.sql.SQLException;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Conditional;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.sojson.config.condition.TaskCondition;
import com.sojson.util.cache.CacheUtil;

import lombok.extern.slf4j.Slf4j;

/**
 * Redis定时任务
 * 
 * @author liu
 * @date 2021-04-28
 */
@Slf4j
@Component
/** 是否注入这个Bean */
@Conditional(TaskCondition.class)
/** 是否注入这个Bean */
@ConditionalOnProperty(name = "so.redis.enabled", havingValue = "true")
public class RedisTask implements TaskInterface {

    /**
     * 清空Redis已超时的属性
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void postsNo() throws SQLException {
        CacheUtil.CACHE_REDIS.flushCache();
        log.info("---------------当天0 清空Redis已超时的属性----------------");
    }

}